var express = require('express');
var router = express.Router();
var casual = require('casual');

var codes = [
    {code:200,message:'操作成功'},
    {code:601,message:'操作失败'},
    {code:602,message:'参数不合法或不正确'},
    {code:611,message:'拿不到cookies'},
    {code:612,message:'拿不到指定ticket那个cookie'},
    {code:613,message:'用户未登录、或登录超时'}
];
/*{"body":"","code":"613","message":"operate successfully"}*/
// {"body":{"name":"占二六","sex":"1","threshold":"1"},"code":"200","message":"operate successfully"}
var userInfo = [
    {"body":{"name":"占二六","sex":"1","threshold":"1"},"code":"200","message":"operate successfully"},
    {"body":{"name":"占二六","sex":"1","threshold":"0"},"code":"200","message":"operate successfully"},
    {body:"",code:601,message:'操作失败'},
    {body:"",code:602,message:'参数不合法或不正确'},
    {body:"",code:611,message:'拿不到cookies'},
    {body:"",code:612,message:'拿不到指定ticket那个cookie'},
    {body:"",code:613,message:'用户未登录、或登录超时'}
];

var payload = casual.random_element(userInfo)

// 根据ticket查询用户信息
router.post('/api/getuserinfo', function (req, res) {
    res.json(payload);
    // {"body":"","code":"613","message":"operate successfully"}
});

router.post('/api/checkSSOLogin', function (req, res) {
    res.json(payload);
});

router.post('/api/userConfigureStatus', function (req, res) {
    res.json({
        body: {configureStatus: "0"}, code: "200", message: "operate successfully"
    })
});

module.exports = router;
